<?php $this->load->view("common/page_header");?>
	<?php $this->load->view("common/top_banner");?>
	<?php $this->load->view("common/header");?>
	
	<div id="body_main">
		<div class="search_top">
			<?php $this->load->view("common/top_login_button");?>
			<div class="title"><span class="orange"><a href="/group/view?group_id=<?php echo $group['id'];?>"><?php echo $group['title']?></a></span>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $thread['title']?></div>
			<div class="clear"></div>
		</div>
		<div class="top_border margin_top15">
			<div class="arrow_up" style="left:50px"></div>
		</div>
		
		<div id="body_content" class="forum_view">
			<div class="top">
				<?php if (!empty($is_group_admin)) {?>
				<div class="forum_admin">
					
					<div class="admin_select" id="admin_select"><a href="javascript:void(0)">主题管理</a></div>
					<ul>
						<li><a href="/group/thread_manager?act=delete&thread_id=<?php echo $thread['id']?>">删除主题</a></li>
						<?php if ($thread['is_down'] == 0) {?>
							<li><a href="/group/thread_manager?act=down&thread_id=<?php echo $thread['id']?>">下沉</a></li>
						<?php } else {?>
							<li><a href="/group/thread_manager?act=undown&thread_id=<?php echo $thread['id']?>">提升</a></li>
						<?php }?>
						<?php if ($thread['is_top'] == 0) {?>
							<li><a href="/group/thread_manager?act=top&thread_id=<?php echo $thread['id']?>">主题置顶</a></li>
						<?php } else {?>
							<li><a href="/group/thread_manager?act=untop&thread_id=<?php echo $thread['id']?>">取消主题置顶</a></li>
						<?php }?>
						<?php if ($thread['highlight'] == 0) {?>
							<li><a href="/group/thread_manager?act=highlight&thread_id=<?php echo $thread['id']?>">高亮显示</a></li>
						<?php } else {?>
							<li><a href="/group/thread_manager?act=unhighlight&thread_id=<?php echo $thread['id']?>">取消高亮显示</a></li>
						<?php }?>
						<?php if ($thread['digest'] == 0) {?>
							<li><a href="/group/thread_manager?act=digest&thread_id=<?php echo $thread['id']?>">设置精华</a></li>
						<?php } else {?>
							<li><a href="/group/thread_manager?act=undigest&thread_id=<?php echo $thread['id']?>">取消设置精华</a></li>
						<?php }?>
						<?php if ($thread['closed'] == 0) {?>
							<li><a href="/group/thread_manager?act=closed&thread_id=<?php echo $thread['id']?>">关闭</a></li>
						<?php } else {?>
							<li><a href="/group/thread_manager?act=unclosed&thread_id=<?php echo $thread['id']?>">打开</a></li>
						<?php }?>
					</ul>
					
				</div>
				<?php } ?>
				<div class="action">
					<?php if ($thread['closed'] != 1) {?>
					<a href="/group/reply_post?thread_id=<?php echo $thread['id'];?>" class="green_button">回复</a>
					<?php }?>
					<a href="/group/newthread?group_id=<?php echo $group['id'];?>" class="green_button">发帖</a>
				</div>
				<?php $this->load->view("common/page_controller");?>
			</div>
			
			<div class="clear"></div>

			<div class="threads">
			<?php if (!empty($posts)) {?>
				<?php foreach($posts as $post) { ?>
				<a name="post-<?php echo $post['id']?>">
				<div class="item" >
					
					<div class="user">
						<a href="/user/show?user_id=<?php echo $post['created_by'];?>"><img src="<?php echo empty($post['thumb_avatar']) ?'/img/user.png' : '/img/avatar/' . $post['thumb_avatar'];?>" class="profile" /></a>
						<ul>
							<li><a href="/user/show?user_id=<?php echo $post['created_by'];?>"><?php echo $post['nickname']?></a></li>
							<li>身份验证：<?php echo $post['vertification']?></li>
							<li>好评：
							<?php for($i = 0; $i < floor($post['score']) && $i < 5; $i++) {?>
								<img src="/img/star-on.png" />
							<?php }?>
						</li>
							<li>来自：<?php echo $post['address'];?></li>
						</ul>
					</div>
					<div class="content">
						<div class="grey">
							发表日期：<?php echo $post['created']?>
							<a href="/group/reply_post?thread_id=<?php echo $thread['id'];?>&post_id=<?php echo $post['id']?>" class="right">回复</a>
						</div>
						<div class="words">
							
							<?php echo nl2br($post['content']);?>
						</div>
					</div>
					<div class="clear"></div>
				</div>			
				<?php } ?>
				<?php }?>
				<?php $this->load->view("common/page_controller");?>
			</div>
			
			<div class="clear"></div>
			<?php if ($thread['closed'] != 1) {?>
				<div class="item" style="padding-left:25px;">
					<form method="post" action="/group/reply_post">
						<div class="form_row">
							<label class="input_label"><span class="red">*</span>快速回复：</label>
							<textarea class="input_textarea" name="content"></textarea>
						</div>
						<div class="form_action">
							<input type="submit" class="input_button" value="回复" />
							<input type="hidden" name="group_id" value="<?php echo $thread['group_id'];?>">
							<input type="hidden" name="thread_id" value="<?php echo $thread['id'];?>">
						</div>
						
					</form>
					<div class="clear"></div>
				</div>
			<?php }?>
		</div>
		
		<?php $this->load->view("common/footer");?>		
		
		<p class="center">Page rendered in {elapsed_time} seconds</p>
	</div>
<script type="text/javascript">
$('#admin_select').click(function(event){
	$(this).parent().find('ul').toggle();
	event.stopPropagation();
});
$(document).click(function(){
	$('.forum_admin').find('ul').hide();
});
$(document).ready(function(){
	$("#register_button").colorbox({iframe:true, innerWidth:556, innerHeight:320, close:'关闭'});
	$("#login_button").colorbox({iframe:true, innerWidth:390, innerHeight:180, close:'关闭'});
});	
</script>
<?php $this->load->view("common/page_footer");?>
